﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Vega.USiteBuilder;
using SPCFMedicineInformer.Members;

namespace SPCFMedicineInformer.Masterpages
{
    public partial class ContentAccount_MyConsultation : System.Web.UI.MasterPage
    {
        int id = 0;
        string user = string.Empty;
        int userId = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            var User = HttpContext.Current.User.Identity;
            var member = MemberHelper.GetMemberFromEmail(User.Name) as WebUser;
            if (!IsPostBack)
            {
                if (member != null)
                {
                    user = member.Email.ToLower();
                    userId = member.Id;
                    id = member.Id;
                    BindGrid();
                }

            }
        }
        void BindGrid()
        {
            var consultations = NodeLocator.GetNodesOfExactType<DocumentTypes.Consultation>().Where(a => a.UserId == userId.ToString()).ToList().OrderByDescending(a=>a.Id);
            dgrItems.DataSource = consultations;
            dgrItems.DataBind();
        }
    }
}